<%@ page import="java.io.File" %>
<%@ page import="java.net.URLEncoder" %>
<%@ page import="TeachLesson.Res.ResDao" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="TeachLesson.Res.ResEnity" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/8/26
  Time: 22:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<%
    String point=request.getParameter("point");
    String dirName=request.getParameter("dirName");
    String courseNo=(String)session.getAttribute("courseNo");
    String workerNo=(String) session.getAttribute("workerNo");

    response.setCharacterEncoding("GBK");
    request.setCharacterEncoding("GBK");
%>
<head>
    <title>知识点文件</title>
    <link href="/SystemerNav/SystemerNav.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

</head>
<body background="/LoginInterface/loginFace.jpg">
<div class="container">
    <div class="top">
        <form action="/TeachLesson/UploadKonwledgeFileServlet" enctype="multipart/form-data" method="post">
            <input type="hidden" name="point" value="<%=point%>">
            <input type="hidden" name="dirName" value="<%=dirName%>">
            <input type="hidden" name="workerNo" value="<%=workerNo%>">
            <input type="hidden" name="courseNo" value="<%=courseNo%>">
        <div class="form-group">
            <label for="exampleInputFile">上传文件</label>
            <input type="file" id="exampleInputFile" name="t1">
            <button type="submit" class="btn btn-info">上传</button>
        </div>
        </form>

        <table class="table table-hover">
            <tr>
                <td>文件名</td>
                <td>下载</td>
                <td>删除</td>
            </tr>
        <%//遍历文件


          String fileRoot="F:\\JWGLXT\\web\\StoreResoures\\"+workerNo+"\\"+courseNo+"\\"+dirName+"\\"+point;
            ResDao resDao=new ResDao();
            ArrayList<ResEnity> list=resDao.getRes(fileRoot);

         /* out.println(filePath);
            File file=new File(filePath);
            if(!file.exists()){
                file.mkdirs();
            }
            String [] f_array=file.list();
            for (int i=0;i<f_array.length;i++){*/

            for (ResEnity temp:list){

                %>

        <tr>
            <td><%=temp.getFileName()%></td>
            <td>
                <form action="/TeachLesson/downloadResServlet">
                    <input type="hidden" name="id" value="<%=temp.getId()%>">
                    <button type="submit" class="btn btn-success">下载</button>
                </form>
            </td>
            <td>
                <form action="/TeachLesson/deleteResoursesServlet" target="_blank">
                    <input type="hidden" name="id" value="<%=temp.getId()%>">
                    <button type="submit" class="btn btn-danger">删除</button>
                </form>
            </td>
        </tr>


        <%
            }%>
        </table>
    </div>
</div>
</body>
</html>
